﻿using System;
using System.Windows;

namespace Utility3D
{
    public class Camera
    {
        public Camera(Plane viewingPlane, Point3D focalPoint)
        {
            ViewingPlane = viewingPlane;
            FocalPoint = focalPoint;
        }

        public Plane ViewingPlane { get; set; }
        public Point3D FocalPoint { get; set; }

        public Point? ProjectPoint(Point3D point3D)
        {
            var intersection = ViewingPlane.GetIntersection(point3D, FocalPoint - point3D, false);
            if (intersection == null) return null;
            return ViewingPlane.ProjectTo2D(intersection.Value);
        }
    }
}